package cn.tedu.yushouge.pet.adopt.service.impl;

import cn.tedu.yushouge.commons.pojo.vo.PageData;
import cn.tedu.yushouge.commons.util.PageInfoToPageDataConverter;
import cn.tedu.yushouge.pet.adopt.mapper.AdoptRecordMapper;
import cn.tedu.yushouge.pet.adopt.pojo.vo.AdoptListVO;
import cn.tedu.yushouge.pet.adopt.pojo.vo.AdoptRecordListVO;
import cn.tedu.yushouge.pet.adopt.service.IAdoptRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class AdoptRecordServiceImpl implements IAdoptRecordService {

    @Autowired
    AdoptRecordMapper mapper;

    @Override
    public PageData<AdoptRecordListVO> list(Integer pageNum) {
        Integer pageSize = 5;
        return list(pageNum,pageSize);
    }

    @Override
    public PageData<AdoptRecordListVO> list(Integer pageNum, Integer pageSize) {
        log.debug("开始处理【查询相册列表】的业务，页码：{}，每页记录数：{}", pageNum, pageSize);
        PageHelper.startPage(pageNum,pageSize);
        List<AdoptRecordListVO> list = mapper.list();
        PageInfo<AdoptRecordListVO> pageInfo = new PageInfo<>(list);
        PageData<AdoptRecordListVO> pageData = PageInfoToPageDataConverter.convert(pageInfo);
        log.debug("查询完成，即将返回：{}", pageData);
        return pageData;
    }
}
